import 'package:flutter/material.dart';

class TabBarItem extends StatelessWidget {
  final String defaultIconPath;
  final String selectedIconPath;
  final String label;
  final bool isSelected;
  final Color selectedColor;
  final Color unselectedColor;

  const TabBarItem({
    super.key,
    required this.defaultIconPath,
    required this.selectedIconPath,
    required this.label,
    required this.isSelected,
    this.selectedColor = const Color(0xFF000000),
    this.unselectedColor = const Color(0xFF9E9E9E),
  });

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      mainAxisAlignment: MainAxisAlignment.center, // 垂直方向居中
      crossAxisAlignment: CrossAxisAlignment.center, // 水平方向居中
      children: [
        Image.asset(
          isSelected ? selectedIconPath : defaultIconPath,
          width: 18,
          height: 18,
        ),
        // const SizedBox(height: 2), 增加图标和文字的间隙
        Text(
          label,
          style: TextStyle(
            color: isSelected ? selectedColor : unselectedColor,
            fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
            fontSize: 10,
          ),
        ),
      ],
    );
  }
}